<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        var fun = function fun(str) {
            var arr = []
            for (var i = 0; i < str.length - 4; i++) {
                arr.push(str.substr(i, 5))
            }
            arr.sort(function (a, b) {
                return a - b
            })
            return arr[arr.length - 1]
        }("1234567890")
        console.log(fun)
    </script>
</body>

</html>